Skip to content

Conversation

@eavanvalkenburg
Copy link
Member

@eavanvalkenburg eavanvalkenburg commented Feb 7, 2026

Summary

This PR modernizes the Python tooling and dependency management across the monorepo.

Fixes #3578

Changes

Parallelize checks across packages

  • Added scripts/task_runner.py — shared parallel execution engine using ThreadPoolExecutor
  • Updated run_tasks_in_packages_if_exists.py to accept multiple tasks and run (package × task) cross-product in parallel
  • Updated run_tasks_in_changed_packages.py with --files flag and parallel support
  • Added check-packages poe task that runs fmt+lint+pyright+mypy in parallel across all 22 packages
  • Added prek-markdown-code-lint and prek-samples-check with change detection (skip when irrelevant files changed)
  • Core package changes still trigger checks on all packages

Split CI code quality into parallel jobs

  • Split single prek job into 4 parallel jobs: pre-commit hooks, package checks, samples & markdown, mypy
  • Use SKIP=poe-check to run lightweight pre-commit hooks separately from heavy package checks
  • Reduced code quality matrix to Python 3.10 only (from 3.10 + 3.14)

Add from __future__ import annotations and remove quoted types

  • Added from __future__ import annotations to 81 package files that used quoted string annotations
  • Ran pyupgrade --py310-plus to remove the now-unnecessary quotes
  • Excluded 12 files that use runtime annotation introspection (@handler/@response_handler decorators)

Replace pre-commit with prek

  • Replaced pre-commit with prek, a Rust-native drop-in replacement that is significantly faster
  • Moved 5 hooks to repo: builtin for zero-clone, Rust-native execution: check-toml, check-yaml, check-json, end-of-file-fixer, mixed-line-ending
  • Added 4 new builtin hooks: trailing-whitespace, check-merge-conflict, detect-private-key, check-added-large-files
  • Updated all hook versions to latest: pre-commit-hooks v6, pyupgrade v3.21.2, bandit 1.9.3, uv-pre-commit 0.10.0
  • Updated CI workflow to use j178/prek-action@v1
  • Updated all poe tasks, scripts, and documentation

PEP 723 inline script metadata for samples

  • Added PEP 723 inline script metadata to 34 sample files that use external dependencies (autogen, semantic-kernel, azure-monitor, etc.)
  • Each sample now includes a run comment: uv run samples/path/to/script.py
  • This makes samples self-contained and runnable without installing external deps into the workspace

Dev dependency cleanup

  • Removed autogen-agentchat and autogen-ext[openai] from dev deps (now declared per-sample via PEP 723)
  • Removed unused dev deps: pytest-env (no config found), tomli-w (zero imports)

Core version lower bounds

  • Added >=1.0.0b260130 lower bound to agent-framework-core dependency in all 21 non-core packages
  • Ensures consistent minimum version requirements across the monorepo

Documentation updates

  • CODING_STANDARD.md: Added Versioning and Core Dependency section with policy for version bumps
  • SAMPLE_GUIDELINES.md: Extracted sample-specific standards (file structure, PEP 723 usage, syntax checking) into dedicated doc
  • AGENTS.md: Replaced inline sample section with link to SAMPLE_GUIDELINES.md
  • DEV_SETUP.md: Updated all pre-commit references to prek, documented new parallel check behavior

…up dev dependencies

- Replace pre-commit with prek (Rust-native, faster pre-commit alternative)
- Move supported hooks to repo: builtin for zero-clone speed
- Add new builtin hooks: trailing-whitespace, check-merge-conflict, detect-private-key, check-added-large-files
- Update all hook versions to latest (pre-commit-hooks v6, pyupgrade v3.21.2, bandit 1.9.3, uv-pre-commit 0.10.0)
- Add PEP 723 inline script metadata to 34 samples with external deps
- Remove autogen-agentchat/autogen-ext from dev deps (now declared per-sample)
- Remove unused dev deps: pytest-env, tomli-w
- Add agent-framework-core>=1.0.0b260130 lower bound to all 21 packages
- Update CI workflow to use j178/prek-action
- Update docs: DEV_SETUP.md, AGENTS.md, CODING_STANDARD.md, SAMPLE_GUIDELINES.md
@eavanvalkenburg eavanvalkenburg requested a review from a team as a code owner February 7, 2026 13:06
Copilot AI review requested due to automatic review settings February 7, 2026 13:06
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python lab Agent Framework Lab labels Feb 7, 2026
@github-actions github-actions bot changed the title python: replace pre-commit with prek, add PEP 723 script deps, clean up dev dependencies Python: replace pre-commit with prek, add PEP 723 script deps, clean up dev dependencies Feb 7, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 7, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/a2a/agent_framework_a2a
   _agent.py149894%263, 401–402, 439–440, 469–471
packages/ag-ui/agent_framework_ag_ui
   _client.py1511788%85–86, 90–94, 98–102, 265, 297, 466–468
   _endpoint.py47197%94
   _event_converters.py700100% 
   _http_service.py420100% 
   _message_adapters.py4559579%91, 101–102, 111–114, 117–121, 123–128, 131, 140–146, 149, 153–155, 164–166, 186, 192–194, 224, 237–238, 248–249, 286, 289, 291, 294, 297, 313, 330, 352, 383, 388, 399–400, 451, 467–468, 534–537, 539, 545, 553–554, 556, 560–563, 576, 665–668, 670, 736, 771–773, 775–778, 781–782, 784, 790, 793, 795, 798, 800, 806–807, 809
   _run.py48212174%157–164, 307, 326–327, 342–343, 358, 386–388, 413, 416–419, 421–422, 425–431, 434–436, 439, 455–457, 464, 470–472, 476, 481–483, 485–486, 502–506, 517, 530, 532–533, 549, 570–571, 628–630, 642–644, 842, 853–854, 861, 879–881, 915–917, 934, 940, 948, 950, 986–992, 995–998, 1000–1009, 1012, 1020–1023, 1030, 1033–1034, 1039, 1045–1047, 1051, 1056–1059, 1073–1075
   _utils.py102397%74, 259, 264
packages/ag-ui/agent_framework_ag_ui/_orchestration
   _helpers.py1080100% 
   _predictive_state.py99297%144, 216
   _tooling.py580100% 
packages/anthropic/agent_framework_anthropic
   _chat_client.py36415058%373, 405, 407, 422, 444–447, 456, 458, 495–499, 501, 503–504, 506, 511–512, 514, 547–548, 557, 559–560, 565, 582–583, 625, 640, 644–645, 661, 670, 672, 676–677, 720–722, 724, 737–738, 745–747, 751–753, 757–760, 771, 773, 795, 805, 827–833, 840–841, 849–850, 858–861, 868–869, 875–876, 882–883, 889, 897–899, 903, 910–911, 917–918, 924–925, 931, 939–942, 949–950, 969, 976–977, 996, 1018, 1020, 1029–1030, 1036, 1058–1059, 1065–1066, 1075–1085, 1092–1098, 1105–1111, 1118–1127, 1134–1137
packages/azure-ai/agent_framework_azure_ai
   _agent_provider.py116397%124–125, 253
   _chat_client.py4857584%384, 389–390, 392–393, 396, 399, 401, 406, 667–668, 670, 673, 676, 679–684, 687, 689, 697, 709–711, 715, 718–719, 727–730, 740, 748–751, 753–754, 756–757, 764, 772–773, 781–782, 787–788, 792–799, 804, 807, 815, 821, 829–831, 834, 856–857, 990, 1018, 1033, 1152, 1178, 1187, 1196, 1329
   _client.py1961393%362, 364, 413, 442–447, 490, 525, 527, 603
   _project_provider.py116694%134–135, 213, 311, 355, 388
   _shared.py3032292%123, 154, 156, 158, 160, 205, 322–324, 364, 436, 459, 466, 515–516, 519–520, 549, 597, 604, 616, 635
packages/azurefunctions/agent_framework_azurefunctions
   _app.py3698576%204–205, 210–211, 322–323, 431, 439–440, 460–462, 468–470, 476–478, 511–512, 572–573, 622–623, 628, 710, 713, 722–724, 726–728, 730, 732, 743, 745–748, 750, 752–753, 755, 762–763, 765–766, 768–769, 771, 775, 785–787, 789–790, 792–794, 801, 803–804, 806, 827, 832, 844, 919, 929, 936–938, 983, 997, 1008–1010, 1012–1015, 1040, 1047, 1049, 1052
   _entities.py58591%83, 112–114, 116
packages/chatkit/agent_framework_chatkit
   _converter.py1344665%117, 122, 170, 172, 342, 395, 397, 416–418, 420, 438, 440, 442, 445, 457, 467, 485, 505–529, 531–533
packages/copilotstudio/agent_framework_copilotstudio
   _agent.py84594%156–157, 192, 200, 317
packages/core/agent_framework
   _agents.py3213589%475, 887, 923, 1022–1024, 1137, 1178, 1180, 1189–1194, 1200, 1202, 1212–1213, 1220, 1222–1223, 1231–1235, 1243–1244, 1246, 1251, 1253, 1287, 1327, 1347
   _clients.py53394%296, 497, 499
   _mcp.py3895386%113, 175, 184, 247, 255, 276, 366, 433, 468, 470, 474–475, 477–478, 532, 547, 565, 606, 712, 725–730, 752, 773, 776–778, 793–794, 800–802, 821, 830, 833–835, 850–851, 855–859, 876–880, 1020
   _memory.py27196%154
   _pydantic.py260100% 
   _serialization.py106496%518, 534, 544, 612
   _telemetry.py20195%66
   _threads.py137397%345, 476–477
packages/core/agent_framework/_workflows
   _checkpoint_encoding.py1945173%51–54, 58, 64–66, 72–73, 127–128, 146–148, 158–165, 221–222, 229, 233, 242–243, 248–262, 264–270
packages/core/agent_framework/azure
   _assistants_client.py410100% 
   _chat_client.py80495%303, 305, 318–319
   _entra_id_authentication.py240100% 
   _responses_client.py38684%148, 171, 200–203
   _shared.py80791%137–138, 201, 204, 217, 219, 229
packages/core/agent_framework/openai
   _assistant_provider.py1111190%158–159, 171, 296, 362, 477–482
   _assistants_client.py2763587%360, 362, 364, 367, 371–372, 375, 378, 383–384, 386, 389–391, 396, 407, 432, 434, 436, 438, 440, 445, 448, 451, 455, 466, 551, 636, 673, 710–713, 765, 782
   _chat_client.py2682192%181–182, 186, 300, 307, 388–395, 397–400, 410, 495, 532, 548
   _exceptions.py340100% 
   _responses_client.py5636288%279–280, 285, 316, 324, 347, 409, 441, 466, 472, 490–491, 513, 518, 574, 588, 605, 618, 673, 752, 757, 761–763, 767–768, 791, 860, 882–883, 898–899, 917–918, 1049–1050, 1066, 1068, 1143–1151, 1199, 1254, 1269, 1305–1306, 1308–1310, 1324–1326, 1336–1337, 1343, 1358
   _shared.py1361688%65, 71–74, 153, 155, 157, 164, 166, 179, 255, 279, 343–344, 346
packages/mem0/agent_framework_mem0
   _provider.py86693%69–70, 92, 176–177, 180
packages/orchestrations/agent_framework_orchestrations
   _group_chat.py2875182%175, 338, 345, 374, 385–386, 392, 397, 413, 440–445, 447, 480–483, 485, 490–494, 624, 627, 630, 633, 641, 654, 657, 670, 679, 685, 729–730, 734–735, 749–750, 752–753, 784–785, 851, 870, 878, 892, 902
packages/purview/agent_framework_purview
   _client.py1200100% 
   _models.py4579678%222–226, 308, 310, 332, 334, 338, 365, 369, 416–421, 424–431, 442–445, 456–459, 489–490, 493, 495, 497–499, 533, 535, 537, 539, 541, 543, 545, 550–552, 554, 557, 563, 566, 605, 607, 609, 611, 613, 621, 623, 625, 627, 661, 665, 700, 702, 704, 708, 714, 716, 738–739, 764, 766, 768, 772, 791–793, 798–799, 832, 834, 846, 909, 912–916, 918, 946, 977, 979
packages/redis/agent_framework_redis
   _provider.py189995%257, 259, 267, 272–273, 276, 331, 388, 400
TOTAL16592205787% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3920 225 💤 0 ❌ 0 🔥 1m 8s ⏱️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Modernizes the Python developer tooling for the monorepo by switching from pre-commit to prek, cleaning up workspace dev dependencies, and making samples self-contained via PEP 723 inline metadata.

Changes:

  • Replace pre-commit with prek across local tooling and CI, and update hook versions/config.
  • Add PEP 723 inline script metadata to samples that require external dependencies and document new sample guidelines.
  • Normalize non-core packages to depend on agent-framework-core>=1.0.0b260130 and remove unused dev dependencies.

Reviewed changes

Copilot reviewed 64 out of 65 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/uv.lock Removes pre-commit and other no-longer-needed deps; adds prek; updates resolved dependency graph accordingly.
python/pyproject.toml Updates dev dependency group (adds prek, removes pre-commit/unused deps) and renames Poe tasks from pre-commit-* to prek-*.
python/.pre-commit-config.yaml Moves several hooks to repo: builtin, updates hook revisions, and points the Poe hook at prek-check.
.github/workflows/python-code-quality.yml Switches CI job from pre-commit to prek using j178/prek-action@v1 and updates caching paths/keys.
python/devsetup.sh Updates dev setup script to install prek hooks via Poe.
python/DEV_SETUP.md Updates documentation to refer to prek instead of pre-commit and adjusts the suggested commands.
python/CODING_STANDARD.md Documents policy for bumping agent-framework-core lower bounds in non-core packages.
python/AGENTS.md Replaces embedded sample guidance with a link to samples/SAMPLE_GUIDELINES.md.
python/.vscode/tasks.json Updates VS Code task to run prek instead of pre-commit.
python/samples/SAMPLE_GUIDELINES.md Adds explicit sample file structure + PEP 723 dependency guidance and notes on samples syntax checking.
python/samples/semantic-kernel-migration/processes/nested_process.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/processes/fan_out_fan_in_process.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/orchestrations/sequential.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/orchestrations/magentic.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/orchestrations/handoff.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/orchestrations/group_chat.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/orchestrations/concurrent_basic.py Adds PEP 723 metadata and adjusts imports in the orchestration sample.
python/samples/semantic-kernel-migration/openai_responses/01_basic_responses_agent.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/openai_responses/02_responses_agent_with_tool.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/openai_responses/03_responses_agent_structured_output.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/openai_assistant/01_basic_openai_assistant.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/openai_assistant/02_openai_assistant_with_code_interpreter.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/openai_assistant/03_openai_assistant_function_tool.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/copilot_studio/01_basic_copilot_studio_agent.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/copilot_studio/02_copilot_studio_streaming.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/chat_completion/01_basic_chat_completion.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/chat_completion/02_chat_completion_with_tool.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/chat_completion/03_chat_completion_thread_and_stream.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/azure_ai_agent/01_basic_azure_ai_agent.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/azure_ai_agent/02_azure_ai_agent_with_code_interpreter.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/azure_ai_agent/03_azure_ai_agent_threads_and_followups.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/getting_started/observability/agent_with_foundry_tracing.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/getting_started/evaluation/self_reflection/self_reflection.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/getting_started/agents/copilotstudio/copilotstudio_with_explicit_settings.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/demos/chatkit-integration/app.py Adds PEP 723 metadata to make the demo runnable standalone.
python/samples/demos/m365-agent/m365_agent_demo/app.py Adds PEP 723 metadata at top of file (but currently results in duplicated metadata blocks).
python/samples/autogen-migration/single_agent/01_basic_assistant_agent.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/single_agent/02_assistant_agent_with_tool.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/single_agent/03_assistant_agent_thread_and_stream.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/single_agent/04_agent_as_tool.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/orchestrations/01_round_robin_group_chat.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/orchestrations/02_selector_group_chat.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/orchestrations/03_swarm.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/orchestrations/04_magentic_one.py Adds PEP 723 metadata to make the sample runnable standalone.
python/packages/a2a/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/ag-ui/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/anthropic/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/azure-ai-search/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/azure-ai/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/azurefunctions/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/bedrock/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/chatkit/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/claude/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/copilotstudio/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/declarative/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/devui/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/durabletask/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/foundry_local/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/github_copilot/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/lab/pyproject.toml Adds core lower bound and replaces pre-commit with prek in the package’s dev group.
python/packages/mem0/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/ollama/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/orchestrations/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/purview/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/redis/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
Comments suppressed due to low confidence (1)

python/samples/semantic-kernel-migration/orchestrations/concurrent_basic.py:22

  • ConcurrentBuilder is used later in this sample (ConcurrentBuilder(participants=[...]).build()), but it is no longer imported after this change. Add the appropriate import (e.g., from agent_framework.orchestrations import ConcurrentBuilder) or adjust the code to use the correct symbol that is already imported.

Remove global 'files: ^python/' filter and strip python/ prefix from all path patterns in .pre-commit-config.yaml so prek finds files when run from the python/ directory. Update CI workflow to use --cd python instead of --config path. Include trailing whitespace fixes and dev dependency cleanup.
Write a temp pyrightconfig.json matching pyrightconfig.samples.json rules (typeCheckingMode=off, only reportMissingImports and reportAttributeAccessIssue). Filter output to only fail on these rules since syntax-level errors (top-level await, undefined vars) are expected in README documentation snippets.
…list

The prek-markdown-code-lint task received all changed files including non-README markdown and files with pre-existing broken imports. Replace with the standard markdown-code-lint task which uses the correct glob patterns (README.md, packages/**/README.md, samples/**/*.md).
- ag-ui: replace TextContent (removed) with content.type == 'text'
- durabletask: fix import path to durabletask.worker.TaskHubGrpcWorker
- orchestrations: use constructor params instead of .participants() method
- observability: mark deprecated code blocks as plain text, filter
  reportMissingImports to agent_framework modules only
- remove README excludes from markdown-code-lint task
Run (package × task) cross-product in parallel using ThreadPoolExecutor
and subprocesses. Key changes:

- Add scripts/task_runner.py with shared parallel execution engine
- Update run_tasks_in_packages_if_exists.py to accept multiple tasks
- Update run_tasks_in_changed_packages.py with --files flag and parallel support
- Add check-packages poe task (fmt+lint+pyright+mypy in parallel)
- Add prek-markdown-code-lint and prek-samples-check with change detection
- Split CI code quality workflow into parallel prek and mypy jobs
- Update DEV_SETUP.md to document new parallel behavior

Core package changes still trigger checks on all packages.
Split the single prek job into parallel jobs:
- pre-commit-hooks: lightweight hooks (SKIP=poe-check)
- package-checks: fmt/lint/pyright/mypy via check-packages
- samples-markdown: samples-lint, samples-syntax, markdown-code-lint
- mypy: change-detected mypy checks

All 4 jobs run concurrently (×2 Python versions = 8 runners).
Add `from __future__ import annotations` to 93 package files that
used quoted string annotations, then run pyupgrade --py310-plus to
remove the now-unnecessary quotes.

Fixes microsoft#3578
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Feb 9, 2026
Merged via the queue into microsoft:main with commit 977c3ad Feb 9, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation lab Agent Framework Lab python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: all: Use __future__ annotations

4 participants